'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    const { INTEGER, STRING, DATE, TEXT } = Sequelize;
    
    await queryInterface.createTable('roles', {
      id: {
        type: INTEGER,
        primaryKey: true,
        autoIncrement: true
      },
      name: {
        type: STRING(50),
        allowNull: false,
        unique: true,
        comment: '角色名称'
      },
      description: {
        type: STRING(200),
        allowNull: true,
        comment: '角色描述'
      },
      permissions: {
        type: TEXT,
        allowNull: true,
        comment: '权限列表'
      },
      created_at: {
        type: DATE,
        allowNull: false,
        defaultValue: Sequelize.NOW
      },
      updated_at: {
        type: DATE,
        allowNull: false,
        defaultValue: Sequelize.NOW
      }
    });
  },

  down: async (queryInterface, Sequelize) => {
    await queryInterface.dropTable('roles');
  }
};